#include "eventeater.h"

EventEater::EventEater(QObject *parent, std::function<bool(QObject *watched, QEvent *event)> func)
    : QObject{parent}
    , m_func(func)
{
    if (parent) {
        parent->installEventFilter(this);
    }
    else
        deleteLater();
}

bool EventEater::eventFilter(QObject *watched, QEvent *event)
{
    if (m_func(watched, event)){
        return true;
    }

    return QObject::eventFilter(watched, event);
}
